﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="VisualAgile.Web.Views.Login.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../Content/fonts-min.css" rel="stylesheet" type="text/css"></link>

    <script language="javascript">

        Ext.namespace('Extx.login');

        Extx.login.createLoginBox = function(t, s, html) {           
            return ['<div class="msg">',
            '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
            '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><form id="frmLogin" method="post">' + html + '</form></div></div></div>',
            '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
            '</div>'].join('');
        }

        Extx.login.loginWin = function(title, html, remove) {
            if (!Extx.login.msgCt) {
                Extx.login.msgCt = Ext.DomHelper.insertFirst(document.body, { id: 'msg-div' }, true);
            }
            Extx.login.msgCt.alignTo(document, 't-t');
            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            loginWindow = Ext.DomHelper.append(Extx.login.msgCt, { html: Extx.login.createLoginBox(title, s, html) }, true);
            loginWindow.on("click", function() {
                //Ext.get(m).remove();
                //console.log(arguments)
            })
            if (remove) loginWindow.remove();
            else loginWindow.slideIn('t').pause(10);
            setTimeout("Ext.get('users').focus();", 800);
        }        

    </script>

</head>
<body>
    <mvc:ExtScriptManager ID="ExtScriptManager" runat="server" />
    <div id="divContainer">
         
        <div id="loginDiv">
            <% if (ViewData["Users"] != null)
               {%>                        
            <label for="users"><h3>&nbsp;&nbsp;User</h3></label>
            &nbsp;
            <%= Html.DropDownList("", "users", ViewData["Users"])%>
            <%} %>            
            <label for="password"><h3>&nbsp;&nbsp;Password</h3></label>
            &nbsp;
            <%= Html.Password("password", (object)new { @class = "txtSize", @onkeypress = "authenticateFn(event)" })%>

            <script language="javascript">
                function authenticateFn(event) {
                    var charCode;
                    if (event && event.which) {
                        var e = event;
                        charCode = e.which;
                    } else {
                        var e = window.event;
                        charCode = e.keyCode;
                    }

                    if (charCode == 13) {                        
                        //try { Ext.get('name').dom.value = Ext.get('users').dom[Ext.get('users').dom.selectedIndex].text; }
                        //catch(e) {}
                        frmLogin.submit();
                    }
                }
            </script>            
        </div>
        
    </div>

    <script language="javascript">
        var obj = Ext.get('loginDiv').dom;
        var html = obj.innerHTML;
        obj.parentNode.removeChild(obj);
        Extx.login.loginWin("Not Available", "", true);
        Extx.login.loginWin("Not Available", html);
    </script>

</body>
</html>
